using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SCSEngine.Sprite.Implements;
using SCSEngine.Services;
using SCSEngine.ScreenManagement.Implement;
using SCSEngine.ScreenManagement;

namespace TriUan.TriUanGame.GameScreen
{
    class ShapeItem : ListView.IListViewItem
    {
        private SCSServices services;
        private IGameScreenManager _manager;
        public ShapeItem(IGameScreenManager manager, SCSServices services, Sprite shape, Texture2D item)
        {
            this.services = services;
            _manager = manager;
            Item = item;

            Shape = shape;
            Shape.TimeDelay = new TimeSpan(1000000);
            Shape.Play();
        }
        public Rectangle Bound
        {
            get;
            set;
        }
        public Vector2 Position
        {
            get;
            set;
        }

        public Sprite Shape
        {
            get;
            set;
        }

        public Texture2D Item
        {
            get;
            set;
        }

        public string PatternName { get; set; }

        public void Draw(GameTime gameTime)
        {
            Shape.TimeStep(gameTime);
            services.SpritePlayer.Draw(Shape, Position, Color.White);
            services.SpriteBatch.Draw(Item, Position + new Vector2(40,55), null, Color.White, 0, Vector2.Zero, 0.1f, SpriteEffects.None, 1.0f);
        }

        public void Update(GameTime gameTime)
        {
            Bound = new Rectangle((int)Position.X, (int)Position.Y, (int)Item.Width, (int)Item.Height);
        }

        public void Update(Vector2 position)
        {
            Position = position;
            Bound = new Rectangle((int)Position.X, (int)Position.Y, (int)Item.Width, (int)Item.Height);
        }
        public void Tap(GestureSample gesture)
        {
            ClassicGameModeScreenFactory fa = new ClassicGameModeScreenFactory(_manager);
            _manager.AddExclusive(fa.CreateGameScreenWithPattern(PatternName));
        }
    }
}
